package com.bd.scm.module.user.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bd.scm.dao.mapper.user.TransferUserMapper;
import com.bd.scm.domain.models.user.TransferUser;
import com.bd.scm.module.enums.ExceptionEmun;
import com.bd.scm.module.exception.ScmException;
import com.bd.scm.module.user.service.TransferUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TransferUserServiceImpl implements TransferUserService {
    @Resource
    private TransferUserMapper transferUserMapper;

    @Override
    public IPage<TransferUser> transferUserList(Page<TransferUser> page, TransferUser transferUser) {
        return transferUserMapper.transferUserList(page, transferUser);
    }

    @Override
    @Transactional
    public int addLoanInfo(TransferUser j, String clientIp) {
        int r = 0;
        int i = transferUserMapper.addLoanInfo(j);
        if(i>0){
            return 1;
        }else{
            throw new ScmException(ExceptionEmun.USER_ERROR_LOAN);
        }
    }

    /**
     * 获取昨天的永久调用部门数据
     * @return
     */
    @Override
    public List<TransferUser> findBdTemporaryLoanList() {
        return transferUserMapper.findBdTemporaryLoanList();
    }

    /**
     * 导出
     * @param transferUser
     * @return
     */
    @Override
    public List<TransferUser> transferUserList2(TransferUser transferUser) {
        return transferUserMapper.transferUserList2(transferUser);
    }
}
